package com.xiangge.lianxi;

import java.util.Scanner;

public class Demo3 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.println("输入一个正整数:");
        int n = input.nextInt();
        int sum = 0;

        /*for (int i = 0; i <= n; i++) {
            sum +=i;
        }*/

        int i =0;
        while (i<=n){
            sum +=i;
            i++;
        }
        System.out.println("sum = " + sum);
    }
}
